/*
 * MoveView.cpp
 *
 *  Created on: 27/01/2011
 *      Author: Nenem
 */

#include "NormalView.h"

NormalView::NormalView() {
	image = NULL;
	terrain = NULL;
	time = 0;
}

NormalView::~NormalView() {
	if(image != NULL){
		delete image;
	}
}

void NormalView::update(int delta, Model *model, Graphics *graphics){

	time+=delta;

	image->update(model->direction, model->position);

	if(frameRate * time > 1000){
		time = 0;
		image->changeFrame();
	}

	if(model->terrain != NULL){
		if(model->terrain->getTerrain() == NORMAL){
			image->removeTerrain();
		}

		if(model->terrain->getTerrain() != NORMAL){
			image->aplyTerrain(terrain);
		}
	}



	graphics->sprites.push_back(image);

}

void NormalView::setFrameRate(int frameRate){
	this->frameRate = frameRate;
}

Image *NormalView::getImage(){
	return image;
}

void NormalView::setImage(Image *image){
	this->image = image;
}
